import LayerManager from './layerManager'
import ToolManager from './toolManager'

export class Action {
  constructor(viewer, cesium) {
    this._viewer = viewer
    this._cesium = cesium
    this._layerManager = null
    this._toolManager = null
  }

  get layerManager() {
    if (!this._layerManager) {
      this._layerManager = new LayerManager(this._viewer)
    }
    return this._layerManager
  }

  get toolManager() {
    if (!this._toolManager) {
      this._toolManager = new ToolManager(
        this._viewer,
        this._cesium
      )
    }
    return this._toolManager
  }

  get viewer() {
    return this._viewer
  }

  destroy() {
    this._viewer.destroy()
    this._layerManager = null
  }
}
